Skip to content

hwmon: surface_temp: Expose sensor 9 offset via HWMON_T_OFFSET - #212

Open
neveltyc wants to merge 3 commits into
linux-surface:v7.3-surface-develfrom
neveltyc:slg-temp-offset
Open

neveltyc wants to merge 3 commits into
linux-surface:v7.3-surface-develfrom
neveltyc:slg-temp-offset

Conversation

@neveltyc

Copy link
Copy Markdown

Based on #198.

This PR exposes the EC sensor offset command TMP 0x24 for sensor 9 through surface_temp and enables it on the Surface Laptop Go 1.

1. hwmon: surface_temp: Expose sensor 9 offset via HWMON_T_OFFSET

  • Problem: The EC drives its fan curve from virtual sensor I_VTS1 on channel 9. On Windows, the Surface Management Framework adjusts I_VTS1 by writing a temperature offset via TMP command 0x24. Without a driver interface, user-space thermal control has to send raw packets through /dev/surface/aggregator as root.
  • Change: Expose TMP command 0x24 on channel 9 as the standard hwmon temp9_offset attribute in millidegrees Celsius, gated by the has_offset device property.
  • Safety: Clamp the offset to ±5000 millidegrees Celsius, and reset the EC offset to 0 at probe, driver removal, and system shutdown so that the cached value and EC RAM stay in sync.

2. platform/surface: aggregator_registry: Enable sensor offset on Surface Laptop Go 1

  • Problem: TMP command 0x24 has no response, and firmware support varies across Surface models. ssam_node_group_slg1 is shared by the Surface Laptop Go 1, 2, and 3, while offset writes have only been tested on the Surface Laptop Go 1.
  • Change: Add ssam_node_tmp_sensors_with_offset with the has_offset property for ssam_node_group_slg1, and split ssam_node_group_slg2 out for the Surface Laptop Go 2 and 3 so they keep the read-only sensor node until tested on hardware.

Testing

Tested on a Surface Laptop Go 1 with ACPI ID MSHW0118 and SAM firmware 7.100.139:

  • Only temp9_offset is created under the surface_thermal hwmon device.
  • Values outside ±5000 millidegrees Celsius are clamped to ±5000.
  • Writing an offset to temp9_offset shifts temp9_input by the requested amount on the next 5-second EC tick and adjusts the fan speed accordingly.
  • Loading, unloading, or shutting down the driver resets the EC offset to 0.

…eed for Surface Laptop Go

The Surface Laptop Go EC provides the same thermal sensor and fan speed
interfaces as newer Surface models, but ssam_node_group_slg1 does not
register them yet. Add both nodes so that surface_temp and surface_fan
can bind.

On the Surface Laptop Go 1, the separate fan profile command has no
effect, so keep ssam_node_tmp_perf_profile without the has_fan property.

ssam_node_group_slg1 is shared by the Surface Laptop Go 1, 2, and 3.
This change has only been tested on a Surface Laptop Go 1, where
surface_temp exposes the 11 EC thermal channels and surface_fan reports
the fan speed; the Go 2 and Go 3 have not been tested on hardware.

Signed-off-by: Yuchao Tang <neveltyc@gmail.com>
The SAM thermal subsystem supports applying a temperature offset via
command 0x24. On Windows, the Surface Management Framework uses this
command on sensor 9, which corresponds to the virtual sensor I_VTS1
that drives the EC fan curve.

Command 0x24 takes a 5-byte payload containing the 1-based sensor index
followed by a 32-bit IEEE 754 float offset in degrees Celsius, and has
no response. Consequently, writes appear to succeed even on models or
channels where the EC does not implement the command.

Expose this command as the hwmon temp9_offset attribute in millidegrees
Celsius, gated by the has_offset device property so it is only created
on verified devices. Clamp the written value to +/- 5000 millidegrees
Celsius and reset the EC offset to 0 at probe, driver removal, and
system shutdown so the cached value and EC RAM stay in sync.

Tested on a Surface Laptop Go 1, where writing to temp9_offset shifts
temp9_input by the requested amount on the next EC update tick and
adjusts the fan speed accordingly.

Link: linux-surface/linux-surface#2383
Signed-off-by: Yuchao Tang <neveltyc@gmail.com>
…e Laptop Go 1

Add a thermal sensor software node with the has_offset property and use
it for the Surface Laptop Go 1, where sensor 9 offset writes via command
0x24 have been verified on hardware.

Split ssam_node_group_slg2 out from ssam_node_group_slg1 so that the
Surface Laptop Go 2 and 3 keep the regular thermal sensor node until
offset support is tested on them.

Link: linux-surface/linux-surface#2383
Signed-off-by: Yuchao Tang <neveltyc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant